#define GPIOI_IDR     (*((volatile unsigned int*)(0x40022000 +0x10)));
void led_init(void);
void key_init(void);
void delay(volatile unsigned int time);
void PI4_ON(void);
void PI4_OFF(void);

int  main()
{
  led_init();
	key_init();
	static char i=0;
	while(1)
	{
		int keyNum=GPIOI_IDR;
		char keyPI=(keyNum>>4)&1;
		if(keyPI==0)
    {
			delay(5000);
			keyNum=GPIOI_IDR;
			keyPI=(keyNum>>4)&1;
			if(keyPI==1)
			{	
				if(i==0)
				{
					PI4_ON();
					delay(0xfffff);
					i=1;
				}
				else 
				{
					PI4_OFF();
					delay(0xfffff);
					i=0;
				}
			}
		}
	}
}
